using Godot;
using System;

public partial class ArenaTimeUI : CanvasLayer
{
	[Export]
	public ArenaTimeManager ArenaTimeManager;
	private Label label;
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
		label = GetNode<Label>("%Label");
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
		if(ArenaTimeManager == null){
			return ;
		}
		double timeElapsed = ArenaTimeManager.GetTimeElapsed();

		label.Text = FormatSecondsToString(timeElapsed);
	}

	public String FormatSecondsToString(double seconds){
		var minutes = Math.Floor(seconds/60);
		var remainingSeconds = seconds - minutes*60;
		return minutes.ToString()+":"+Convert.ToInt32(Math.Floor(remainingSeconds)).ToString("D2");  //ToString("D2")  补0
	}
}
